package org.mybatis.core.typehandler;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class StringToStringBuffer  extends BaseTypeHandler<StringBuffer>{
	protected static final Logger logger = LoggerFactory.getLogger(StringToStringBuffer.class);
	@Override
	public void setNonNullParameter(PreparedStatement ps, int i, StringBuffer parameter, JdbcType jdbcType)
			throws SQLException {
			ps.setString(i, parameter.toString());
	}

	@Override
	public StringBuffer getNullableResult(ResultSet rs, String columnName) throws SQLException {
		return  new StringBuffer(rs.getString(columnName));
	}

	@Override
	public StringBuffer getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
		return  new StringBuffer(rs.getString(columnIndex));
	}

	@Override
	public StringBuffer getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
		return  new StringBuffer(cs.getString(columnIndex));
	}

}
